/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-06-01 14:56:00
 * @LastEditTime : 2023-06-01 14:56:55
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\LabDataSource.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'

export const LabDataSource = async ({ url, OptionsEvent, Permission }) => {
    let data = {
        type: '试验事务',
        pageSize: 10,
        params: { pageIndex: 1 },
        hideInSearch: true,
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '6c9b8245-c66a-4d00-9306-b62ecdb4f6c4') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.tableName, title: '来源名称' },
            {
                dataIndex: 'originalDataTable',
                title: '原始数据表名称',
                valueType: 'input',
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'judgementDataTable',
                title: '判定标准表名称',
                valueType: 'input',
                rules: true,
                width: 200,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === 'cb623213-82bf-4016-a477-7e156f8e3964') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === '1352954b-c346-4b75-a0d5-067b54d97061') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
